package be.kuleuven.thesis.framework;

import java.util.HashSet;
import java.util.Set;

public class Filter {
	public static final int MIN_YEAR = 1949;
	public static final int MAX_YEAR = 2012;
	public static final int MIN_TEMPO = 20;
	public static final int MAX_TEMPO = 320;
	public static final int MIN_POP = 2;
	public static final int MAX_POP = 7;
	public static final int MIN_HARD = 1;
	public static final int MAX_HARD = 7;
	public static final Atmosphere[] ATMOSPHERES = {Atmosphere.CHEERFUL, Atmosphere.COSY, Atmosphere.ENERGETIC, Atmosphere.EXUBERANT, Atmosphere.FANTASTICAL,
		Atmosphere.HAPPY, Atmosphere.MYSTERIOUS, Atmosphere.RELAX, Atmosphere.ROMANTIC, Atmosphere.SERENE, Atmosphere.STIMULATING};
	public static final String[] GENRES = {};
	public static final String[] MOODS = {};
	
	private int minYear = Filter.MIN_YEAR;
	private int maxYear = Filter.MAX_YEAR;
	private int minTempo = Filter.MIN_TEMPO;
	private int maxTempo = Filter.MAX_TEMPO;
	private int minPop = Filter.MIN_POP;
	private int maxPop = Filter.MAX_POP;
	private int minHard = Filter.MIN_HARD;
	private int maxHard = Filter.MAX_HARD;
	private Set<Atmosphere> atmospheres = new HashSet<Atmosphere>();
	private Set<String> includedGenres = new HashSet<String>();
	private Set<String> excludedGenres = new HashSet<String>();
	private Set<String> includedMoods = new HashSet<String>();
	
	public Filter() {
		atmospheres = getAllAtmospheres();
	}
	
	public Set<Atmosphere> getAllAtmospheres() {
		Set<Atmosphere> atmospheres = new HashSet<Atmosphere>();
		for(int i=0; i < ATMOSPHERES.length; i++) {
			atmospheres.add(ATMOSPHERES[i]);
		}
		return atmospheres;
	}
	
	public Filter clone() {
		Filter copy = new Filter();
		copy.setMinYear(getMinYear());
		copy.setMaxYear(getMaxYear());
		copy.setMinTempo(getMinTempo());
		copy.setMaxTempo(getMaxTempo());
		copy.setMinPop(getMinPop());
		copy.setMaxPop(getMaxPop());
		copy.setMinHard(getMinHard());
		copy.setMaxHard(getMaxHard());
		copy.setAtmospheres(atmospheres);
		copy.setIncludedGenres(getIncludedGenres());
		copy.setExcludedGenres(getExcludedGenres());
		copy.setIncludedMoods(getIncludedMoods());
		return copy;
	}
	
	public void reset() {
		minYear = Filter.MIN_YEAR;
		maxYear = Filter.MAX_YEAR;
		minTempo = Filter.MIN_TEMPO;
		maxTempo = Filter.MAX_TEMPO;
		minPop = Filter.MIN_POP;
		maxPop = Filter.MAX_POP;
		minHard = Filter.MIN_HARD;
		maxHard = Filter.MAX_HARD;
		atmospheres = getAllAtmospheres();
		includedGenres.clear();
		excludedGenres.clear();
		includedMoods.clear();
	}
	
	public boolean isDontCare() {
		return minYear == Filter.MIN_YEAR &&
			maxYear == Filter.MAX_YEAR &&
			minTempo == Filter.MIN_TEMPO &&
			maxTempo == Filter.MAX_TEMPO &&
			minPop == Filter.MIN_POP &&
			maxPop == Filter.MAX_POP &&
			minHard == Filter.MIN_HARD &&
			maxHard == Filter.MAX_HARD &&
			atmospheres == getAllAtmospheres() &&
			includedGenres.isEmpty() &&
			excludedGenres.isEmpty() &&
			includedMoods.isEmpty();
	}

	public int getMinYear() {
		return minYear;
	}

	public void setMinYear(int minYear) {
		this.minYear = minYear;
	}

	public int getMaxYear() {
		return maxYear;
	}

	public void setMaxYear(int maxYear) {
		this.maxYear = maxYear;
	}

	public int getMinTempo() {
		return minTempo;
	}

	public void setMinTempo(int minTempo) {
		this.minTempo = minTempo;
	}

	public int getMaxTempo() {
		return maxTempo;
	}

	public void setMaxTempo(int maxTempo) {
		this.maxTempo = maxTempo;
	}

	public int getMinPop() {
		return minPop;
	}

	public void setMinPop(int minPop) {
		this.minPop = minPop;
	}

	public int getMaxPop() {
		return maxPop;
	}

	public void setMaxPop(int maxPop) {
		this.maxPop = maxPop;
	}

	public int getMinHard() {
		return minHard;
	}

	public void setMinHard(int minHard) {
		this.minHard = minHard;
	}

	public int getMaxHard() {
		return maxHard;
	}

	public void setMaxHard(int maxHard) {
		this.maxHard = maxHard;
	}
	
	public Set<Atmosphere> getAtmospheres() {
		return atmospheres;
	}
	
	public void addAtmosphere(Atmosphere atmosphere) {
		atmospheres.add(atmosphere);
	}
	
	public void removeAtmosphere(Atmosphere atmosphere) {
		atmospheres.remove(atmosphere);
	}

	public void setAtmospheres(Set<Atmosphere> atmospheres) {
		this.atmospheres = atmospheres;
	}

	public Set<String> getIncludedGenres() {
		return includedGenres;
	}

	public void setIncludedGenres(Set<String> genres) {
		this.includedGenres = genres;
	}
	
	public Set<String> getExcludedGenres() {
		return excludedGenres;
	}

	public void setExcludedGenres(Set<String> genres) {
		this.excludedGenres = genres;
	}

	public Set<String> getIncludedMoods() {
		return includedMoods;
	}

	public void setIncludedMoods(Set<String> moods) {
		this.includedMoods = moods;
	}
}
